const Model = require("../../models");
const { PB_TYPE } = require("../../sys_config");

module.exports = {
  name: "pb",

  //初始化排班类型 在服务已开启就执行 在boostrap中
  async init_pb() {
    let model = Model.models.pb;
    if (await model.is_pb_data_initial()) return;
    //获取早午晚的组合
    const time = model.get_pb_initial_data(PB_TYPE.TIME);
    //获取周一至七的组合
    const date = model.get_pb_initial_data(PB_TYPE.DATE);
    try {
      return await model.core.bulkCreate([...time, ...date]);
    } catch (e) {
      console.log(e);
    }
  },
};
